package org.wlc;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.wlc.service.UserService;
import org.wlc.service.UserService2;
import org.wlc.xxx.controller.UserController;

/**
 * Hello world!
 */
public class App {

    private static ApplicationContext context;

    public static void main(String[] args) {

        method04();
    }

    public  static void method04(){
        context = new ClassPathXmlApplicationContext("Spring2.xml");

        org.wlc.xxx.UserService userService = (org.wlc.xxx.UserService) context.getBean("userService");
        userService.test();

    }
    /**
     * SpringIOC 容器扫描范围
     */
    public static void method03(){
        context = new ClassPathXmlApplicationContext("Spring2.xml");

        UserController userController = (UserController) context.getBean("userController");
        userController.test();

    }

    /**
     * @Autowire注解注入
     */
    public static void method02(){
        context = new ClassPathXmlApplicationContext("Spring.xml");
        UserService2 userService2 = (UserService2) context.getBean("userService2");
        userService2.test();
    }

    /**
     * @Resources 注解自动注入
     */
    public static void method01() {
        context = new ClassPathXmlApplicationContext("Spring.xml");
        UserService userService = (UserService) context.getBean("userService");
        userService.test();
    }
}
